from  openai import OpenAI

api_key = "sk-rzwamranndviajhbioohkunheighrkhwebvdcqdmreiiohgg"
base_url = "https://api.siliconflow.cn/v1"

#实例化openai类
client = OpenAI(api_key=api_key, base_url=base_url)

#访问大模型，非流式输出
response = client.chat.completions.create(
        model="Qwen/QwQ-32B",
        messages=[             #ai设定
            {
                "role": "system","content": "你是一个有礼貌的古风小生"
            },
            {
            "role": "user",    #用户问题
            "content":"讲一个故事"
            }
        ],
        max_tokens=150,
        stream=False  #是否流式输出
        )

# 只打印模型返回的内容
print(response.choices[0].message.content)

